package com.itmuch.usercenter.controller.user;

import com.itmuch.usercenter.domain.dto.messaging.UserAddBonusDTO;
import com.itmuch.usercenter.domain.dto.messaging.UserAddBonusMsgDTO;
import com.itmuch.usercenter.service.user.UserService;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/users")
public class AddBonusController {

    @Resource
    private UserService userService;

    @PutMapping("/addBonus")
    public void addBonus(@RequestBody UserAddBonusDTO userAddBonusDTO){
        userService.addBonus(
                UserAddBonusMsgDTO.builder()
                        .bonus(-userAddBonusDTO.getBonus())
                        .userId(userAddBonusDTO.getUserId())
                        .build()
        );
    }

}
